<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>CSS3 | 学习笔记</title><meta name="author" content="lzoxun"><meta name="copyright" content="lzoxun"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="CSS3新增属性xxxxxxxxx 移动端适配屏幕尺寸 设备屏幕尺寸是指屏幕对角线的长度， 1英寸&#x3D;2.54cm     查看大部分设备尺寸 屏幕分辨率 屏幕分辨率是指屏幕的逻辑像素点 数  像素参考资料  物理像素     1366x768设备屏幕的物理像素是指横向1366与纵向768个发光的点组成的设备屏幕  物理像素|设备像素dp(device pixels)设备固定属性，设备像素">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS3">
<meta property="og:url" content="http://example.com/2023/07/22/web/style/style-css3/index.html">
<meta property="og:site_name" content="学习笔记">
<meta property="og:description" content="CSS3新增属性xxxxxxxxx 移动端适配屏幕尺寸 设备屏幕尺寸是指屏幕对角线的长度， 1英寸&#x3D;2.54cm     查看大部分设备尺寸 屏幕分辨率 屏幕分辨率是指屏幕的逻辑像素点 数  像素参考资料  物理像素     1366x768设备屏幕的物理像素是指横向1366与纵向768个发光的点组成的设备屏幕  物理像素|设备像素dp(device pixels)设备固定属性，设备像素">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png">
<meta property="article:published_time" content="2023-07-22T07:14:09.694Z">
<meta property="article:modified_time" content="2023-07-22T07:14:09.694Z">
<meta property="article:author" content="lzoxun">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/2023/07/22/web/style/style-css3/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"top_n_per_article":1,"unescape":true,"languages":{"hits_empty":"找不到您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'CSS3',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-07-22 15:14:09'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          const now = new Date()
          const hour = now.getHours()
          const isNight = hour <= 6 || hour >= 18
          if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
          else if (t === 'light') activateLightMode()
          else activateDarkMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><script>(()=>{
  const $loadingBox = document.getElementById('loading-box')
  const $body = document.body
  const preloader = {
    endLoading: () => {
      $body.style.overflow = ''
      $loadingBox.classList.add('loaded')
    },
    initLoading: () => {
      $body.style.overflow = 'hidden'
      $loadingBox.classList.remove('loaded')
    }
  }

  preloader.initLoading()
  window.addEventListener('load',() => { preloader.endLoading() })

  if (false) {
    document.addEventListener('pjax:send', () => { preloader.initLoading() })
    document.addEventListener('pjax:complete', () => { preloader.endLoading() })
  }
})()</script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><hr class="custom-hr"/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog-info"><a href="/" title="学习笔记"><span class="site-name">学习笔记</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">CSS3</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-07-22T07:14:09.694Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-07-22T07:14:09.694Z" title="更新于 2023-07-22 15:14:09">2023-07-22</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="CSS3"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h3 id="CSS3新增属性"><a href="#CSS3新增属性" class="headerlink" title="CSS3新增属性"></a>CSS3新增属性</h3><p>xxx<br>xxx<br>xxx</p>
<h3 id="移动端适配"><a href="#移动端适配" class="headerlink" title="移动端适配"></a>移动端适配</h3><h4 id="屏幕尺寸"><a href="#屏幕尺寸" class="headerlink" title="屏幕尺寸"></a>屏幕尺寸</h4><blockquote>
<p>设备屏幕尺寸是指屏幕<strong>对角线的长度</strong>， 1英寸&#x3D;2.54cm   </p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://screensiz.es/">查看大部分设备尺寸</a></p>
<h4 id="屏幕分辨率"><a href="#屏幕分辨率" class="headerlink" title="屏幕分辨率"></a>屏幕分辨率</h4><blockquote>
<p>屏幕分辨率是指屏幕的<strong>逻辑像素点 数</strong></p>
</blockquote>
<h4 id="像素"><a href="#像素" class="headerlink" title="像素"></a>像素</h4><p><a target="_blank" rel="noopener" href="https://segmentfault.com/a/1190000011586301">参考资料</a></p>
<ul>
<li><strong>物理像素</strong></li>
</ul>
<blockquote>
<p>  1366x768设备屏幕的物理像素是指横向1366与纵向768个发光的点组成的设备屏幕</p>
</blockquote>
<p>物理像素|设备像素dp(device pixels)<br>设备固定属性，设备像素是固定不变的</p>
<hr>
<ul>
<li><strong>css逻辑像素</strong></li>
</ul>
<p>逻辑像素|css像素<br>css像素是一个相对单位。<br>相对不同屏幕，其实际像素大小不同。<br>我们定义时，是定义其逻辑像素。即该图要用多少个像素来显示。</p>
<hr>
<ul>
<li><strong>设备像素比DPR</strong></li>
</ul>
<p>设备像素比DPR(devicePixelRatio)<br>设备像素&#x2F;(CSS像素|独立像素)<br>DPR &#x3D; 1 设备像素与css像素相等<br>DPR &#x3D; 2 设备像素是css像素两倍<br>dpr可通过window.devicePixelRatio获取</p>
<hr>
<ul>
<li><strong>viewport 视口</strong><ul>
<li>布局视口（layout viewport）<ul>
<li>布局视口定义了pc网页在移动端的默认布局行为</li>
<li>布局视口<code>默认为980px</code>。也就是说在<code>不设置网页的viewport</code>的情况下，pc端的网页<code>默认</code>会以布局视口为基准，在移动端进行展示</li>
</ul>
</li>
<li>视觉视口（visual viewport）<ul>
<li>视觉视口表示浏览器内看到的<code>网站的显示区域</code></li>
<li>用户可以通过缩放来改变视觉视口</li>
</ul>
</li>
<li>理想视口（ideal viewport）<ul>
<li><code>理想视口</code>或者说<code>分辨率</code>就是给定设备物理像素的情况下，最佳的“布局视口”。</li>
</ul>
</li>
<li><a target="_blank" rel="noopener" href="https://juejin.cn/post/6844903630655471624#heading-0">https://juejin.cn/post/6844903630655471624#heading-0</a></li>
</ul>
</li>
</ul>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">mate</span> <span class="attr">name</span>=<span class="string">&#x27;viewport&#x27;</span> <span class="attr">content</span>=<span class="string">&quot;width=device-width,user-scalable=no&quot;</span> /&gt;</span></span><br><span class="line"><span class="comment">&lt;!--</span></span><br><span class="line"><span class="comment">    width=device-width 可视区宽度等于设备显示屏幕宽度</span></span><br><span class="line"><span class="comment">    user-scalable=no   不允许用户手动缩放</span></span><br><span class="line"><span class="comment">    initial-scale=1    初始比例设置100%</span></span><br><span class="line"><span class="comment">    minimum-scale      最小缩放比例(user-scalable=no 不生效)</span></span><br><span class="line"><span class="comment">    maximum-scale      最大缩放比例(user-scalable=no 不生效)</span></span><br><span class="line"><span class="comment">    viewport:</span></span><br><span class="line"><span class="comment">        (1) 一个三百多像素屏幕，打开一个PC页面，要放置一个1000多像素的页面，会混乱，所以会手机浏览器虚拟一个980像素的页面，再进行缩放</span></span><br><span class="line"><span class="comment">        (2) 所以开发移动端时设置width=device-width，把980设置成设备的宽度</span></span><br><span class="line"><span class="comment">        </span></span><br><span class="line"><span class="comment">--&gt;</span></span><br></pre></td></tr></table></figure>

<h3 id="媒体查询"><a href="#媒体查询" class="headerlink" title="媒体查询"></a>媒体查询</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">// 设备宽度小于 <span class="number">960px</span> 时 <span class="selector-tag">body</span>背景变红</span><br><span class="line"><span class="keyword">@media</span> screen <span class="keyword">and</span> (<span class="attribute">max-width</span>: <span class="number">960px</span>)&#123;</span><br><span class="line">    <span class="selector-tag">body</span>&#123;</span><br><span class="line">      <span class="attribute">background-color</span>:<span class="number">#F00</span>；</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/* 在 screen 类型 小于 240px 或 大于360px 小于 700px 加载 */</span></span><br><span class="line"><span class="keyword">@media</span> screen <span class="keyword">and</span> (<span class="attribute">max-width</span>: <span class="number">240px</span>), (<span class="attribute">min-width</span>: <span class="number">360px</span>) <span class="keyword">and</span> (<span class="attribute">max-width</span>: <span class="number">700px</span>) &#123;</span><br><span class="line">    </span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">@media</span> <span class="keyword">not</span> screen &#123;</span><br><span class="line">    xxxx</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">@media</span> <span class="keyword">only</span> screen&#123;</span><br><span class="line">    xxx</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">	设备类型:</span></span><br><span class="line"><span class="comment">		all、screen、print ...</span></span><br><span class="line"><span class="comment">	运算符</span></span><br><span class="line"><span class="comment">		not、and、only、逗号</span></span><br><span class="line"><span class="comment">	常见功能属性</span></span><br><span class="line"><span class="comment">		height                  输出设备中的页面可见区域高度。</span></span><br><span class="line"><span class="comment">        width                   输出设备中的页面可见区域宽度。</span></span><br><span class="line"><span class="comment">        max-aspect-ratio        输出设备的屏幕可见宽度与高度的最大比率。</span></span><br><span class="line"><span class="comment">        max-device-aspect-ratio 输出设备的屏幕可见宽度与高度的最大比率。</span></span><br><span class="line"><span class="comment">        max-device-height       输出设备的屏幕可见的最大高度。</span></span><br><span class="line"><span class="comment">        max-device-width        输出设备的屏幕最大可见宽度。</span></span><br><span class="line"><span class="comment">        max-height              输出设备中的页面最大可见区域高度。</span></span><br><span class="line"><span class="comment">        max-width               输出设备中的页面最大可见区域宽度。</span></span><br><span class="line"><span class="comment">        min-height              输出设备中的页面最小可见区域高度。</span></span><br><span class="line"><span class="comment">        min-width               输出设备中的页面最小可见区域宽度。</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>

<h4 id="加载方式"><a href="#加载方式" class="headerlink" title="加载方式"></a>加载方式</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">// <span class="number">1</span>、标签中 </span><br><span class="line">&lt;source media=&quot;(<span class="attribute">min-width</span>: <span class="number">650px</span>)<span class="string">&quot; srcset=&quot;</span>demo.jpg<span class="string">&quot;&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">// 2、样式中</span></span><br><span class="line"><span class="string">@media only screen&#123;</span></span><br><span class="line"><span class="string">    xxx</span></span><br><span class="line"><span class="string">&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">// 3、样式标签</span></span><br><span class="line"><span class="string">&lt;style media=&quot;</span>(min-width: <span class="number">500px</span>)<span class="string">&quot;&gt;</span></span><br><span class="line"><span class="string">  .box &#123;</span></span><br><span class="line"><span class="string">    background-color: red;</span></span><br><span class="line"><span class="string">  &#125;</span></span><br><span class="line"><span class="string">&lt;/style&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">// 4、第三方文件</span></span><br><span class="line"><span class="string">@import url(./index.css) (min-width:350px);</span></span><br></pre></td></tr></table></figure>



<h3 id="适配方案"><a href="#适配方案" class="headerlink" title="适配方案"></a>适配方案</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">百分比</span></span><br><span class="line"><span class="comment">    width/height(百分比值):相对于父元素</span></span><br><span class="line"><span class="comment">    left/right:position非static的上级元素宽度</span></span><br><span class="line"><span class="comment">    top/bottom:position非static的上级元素高度</span></span><br><span class="line"><span class="comment">    定位元素 padding/margin:position非static 直接父亲元素的width，height无关</span></span><br><span class="line"><span class="comment">    非定位元素 padding/margin:直接父亲元素的width，而与父元素的height无关</span></span><br><span class="line"><span class="comment">    border-radius/translate/background-size等:相对于自生宽度</span></span><br><span class="line"><span class="comment">百分比布局缺点</span></span><br><span class="line"><span class="comment">	宽高相对父元素不一致，计算困难</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>

<h4 id="vw适配方案"><a href="#vw适配方案" class="headerlink" title="vw适配方案"></a>vw适配方案</h4><p><a target="_blank" rel="noopener" href="https://github.com/liaozhongxun/lzo-webfit-postpxtoviewport">Github案例</a></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 计算公式:元素宽度(75px)/设计稿宽度(750px)*100 vw */</span></span><br></pre></td></tr></table></figure>



<h4 id="rem-适配方案"><a href="#rem-适配方案" class="headerlink" title="rem 适配方案"></a>rem 适配方案</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/* 设计稿尺寸/rootValue(基准大小) =&gt; 得到rem大小，rem大小*根字体大小 =&gt; 得到设备显示的具体像素大小 */</span></span><br></pre></td></tr></table></figure>



<ul>
<li>rem只相对于浏览器的根元素（HTML元素）的font-size</li>
<li>在响应式布局中，必须通过js来动态控制根元素font-size的大小。</li>
<li>必须将改变font-size的代码放在css样式之前。</li>
<li>算法: <code>设计稿尺寸/rootValue(基准大小)</code> 得到rem大小，<code>rem大小*根字体大小</code>得到设备的具体像素大小</li>
<li>如果<code>基准翻倍</code>，html<code>字体翻倍</code>，得到的<code>rem值缩小一半</code>，最终设备得到像素大小<code>不变</code></li>
</ul>
<h5 id="vue2"><a href="#vue2" class="headerlink" title="vue2"></a>vue2</h5><p><a target="_blank" rel="noopener" href="https://github.com/liaozhongxun/lzo-webfit-pxtorem-vue2">Github案例</a></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">1.通过 vue init webpack my-project 搭建vue2 webpack项目</span></span><br><span class="line"><span class="comment">2.映入rem文件动态设置html的字体大小</span></span><br><span class="line"><span class="comment">import &quot;./rem&quot;;</span></span><br><span class="line"><span class="comment">3.安装 postcss-pxtorem@5.1.1</span></span><br><span class="line"><span class="comment">4..postcssrc.js 配置 postcss-pxtorem</span></span><br><span class="line"><span class="comment">----------------------------------------------.postcssrc.js</span></span><br><span class="line"><span class="comment">module.exports = &#123;</span></span><br><span class="line"><span class="comment">  &quot;plugins&quot;: &#123;</span></span><br><span class="line"><span class="comment">    &quot;postcss-pxtorem&quot;: &#123; </span></span><br><span class="line"><span class="comment">          rootValue: 16, //结果为：设计稿元素尺寸/16，比如元素宽320px,最终页面会换算成 20rem</span></span><br><span class="line"><span class="comment">          rootValue: 32, //结果为：设计稿元素尺寸/32，比如元素宽750px,最终页面会换算成 23.4375rem</span></span><br><span class="line"><span class="comment">          propList: [&quot;*&quot;], //是一个存储哪些将被转换的属性列表，这里设置为[&#x27;*&#x27;]全部，假设需要仅对边框进行设置，可以写[&#x27;*&#x27;, &#x27;!border*&#x27;]</span></span><br><span class="line"><span class="comment">          unitPrecision: 5, //保留rem小数点多少位</span></span><br><span class="line"><span class="comment">          selectorBlackList: [&#x27;.radius&#x27;],  //则是一个对css选择器进行过滤的数组，比如你设置为[&#x27;fs&#x27;]，那例如fs-xl类名，里面有关px的样式将不被转换，这里也支持正则写法。</span></span><br><span class="line"><span class="comment">		  selectorBlackList: [/^(?!\.mrms-).*斜杠], //只要不是.mrms-开头的类都排除，保留px</span></span><br><span class="line"><span class="comment">		  selectorBlackList: [/^(?!\.(mrms|ivu)-).*斜杠], // 只要不是.mrms-或.ivu-开头的类都排除，保留px</span></span><br><span class="line"><span class="comment">          replace: true, //是否直接替换</span></span><br><span class="line"><span class="comment">          mediaQuery: false, //媒体查询( @media screen 之类的)中不生效</span></span><br><span class="line"><span class="comment">          minPixelValue: 12, //px小于12的不会被转换</span></span><br><span class="line"><span class="comment">    &#125;</span></span><br><span class="line"><span class="comment">  &#125;</span></span><br><span class="line"><span class="comment">&#125;</span></span><br><span class="line"><span class="comment">-----------------------------------------------------</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">5.项目中按ui稿正常填写像素大小，解析后自动转为rem单位</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>

<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//rem.js</span></span><br><span class="line"><span class="comment">// 基准大小</span></span><br><span class="line"><span class="keyword">const</span> baseSize = <span class="number">32</span>; <span class="comment">//与 post-pxtorem 的 rootValue 一致</span></span><br><span class="line"><span class="comment">// 设置 rem 函数</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">setRem</span>(<span class="params"></span>) &#123;</span><br><span class="line">  <span class="comment">// 当前页面宽度相对于 750 宽的缩放比例，可根据自己需要修改。</span></span><br><span class="line">  <span class="comment">// iPhone678 375，baseSize为32,这是 得到跟节点大小为 16px</span></span><br><span class="line">  <span class="keyword">const</span> scale = <span class="variable language_">document</span>.<span class="property">documentElement</span>.<span class="property">clientWidth</span> / <span class="number">750</span>;</span><br><span class="line">  <span class="comment">// 设置页面根节点字体大小</span></span><br><span class="line">  <span class="variable language_">document</span>.<span class="property">documentElement</span>.<span class="property">style</span>.<span class="property">fontSize</span> =</span><br><span class="line">    baseSize * <span class="title class_">Math</span>.<span class="title function_">min</span>(scale, <span class="number">2</span>) + <span class="string">&quot;px&quot;</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 初始化</span></span><br><span class="line"><span class="title function_">setRem</span>();</span><br><span class="line"><span class="comment">// 改变窗口大小时重新设置 rem</span></span><br><span class="line"><span class="variable language_">window</span>.<span class="property">onresize</span> = <span class="keyword">function</span>(<span class="params"></span>) &#123;</span><br><span class="line">  <span class="title function_">setRem</span>();</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>

<h5 id="vue3"><a href="#vue3" class="headerlink" title="vue3"></a>vue3</h5><blockquote>
<p>  <code>.postcssrc.js</code> 改为 <code>postcss.config.js</code></p>
</blockquote>
<p><a target="_blank" rel="noopener" href="https://github.com/liaozhongxun/lzo-webfit-pxtorem">Github</a></p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment">1.通过 vue create 项目名称</span></span><br><span class="line"><span class="comment">2.映入rem文件动态设置html的字体大小</span></span><br><span class="line"><span class="comment">import &quot;./rem&quot;;</span></span><br><span class="line"><span class="comment">3.安装 postcss-pxtorem@5.1.1</span></span><br><span class="line"><span class="comment">4.postcss.config.js 配置 postcss-pxtorem</span></span><br><span class="line"><span class="comment">----------------------------------------------.postcssrc.js</span></span><br><span class="line"><span class="comment">module.exports = &#123;</span></span><br><span class="line"><span class="comment">    &quot;postcss-pxtorem&quot;: &#123;</span></span><br><span class="line"><span class="comment">        rootValue: 32</span></span><br><span class="line"><span class="comment">		xxx</span></span><br><span class="line"><span class="comment">    &#125;,</span></span><br><span class="line"><span class="comment">  &#125;,</span></span><br><span class="line"><span class="comment">&#125;;</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">-----------------------------------------------------</span></span><br><span class="line"><span class="comment"></span></span><br><span class="line"><span class="comment">5.项目中按ui稿正常填写像素大小，解析后自动转为rem单位</span></span><br><span class="line"><span class="comment">*/</span></span><br></pre></td></tr></table></figure>








<h3 id="移动端常用默认样式"><a href="#移动端常用默认样式" class="headerlink" title="移动端常用默认样式"></a>移动端常用默认样式</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-tag">a</span>,<span class="selector-tag">input</span>,<span class="selector-tag">button</span> &#123;</span><br><span class="line">    -webkit-tap-highlight-<span class="attribute">color</span>: <span class="built_in">rgba</span>(<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>); <span class="comment">/*清除点击阴影*/</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">input</span>,</span><br><span class="line"><span class="selector-tag">button</span> &#123;</span><br><span class="line">  -webkit-appearance: none; <span class="comment">/*清除ios圆角*/</span></span><br><span class="line">  <span class="attribute">border-radius</span>: <span class="number">0</span>; <span class="comment">/*清除ios输入框默认圆角*/</span></span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">body</span> &#123;</span><br><span class="line">  <span class="attribute">margin</span>: <span class="number">0</span>;</span><br><span class="line">  -webkit-user-select: none; <span class="comment">/*禁止选中文字*/</span></span><br><span class="line">  <span class="attribute">font-family</span>: helvetica; <span class="comment">/*默认字体*/</span></span><br><span class="line">  -webkit-text-size-adjust: <span class="number">100%</span>; <span class="comment">/*用户横竖屏切换的时候，禁止字体缩放*/</span></span><br><span class="line">  <span class="attribute">font-family</span>: helvetica; <span class="comment">/*默认字体*/</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="selector-tag">h1</span> &#123;</span><br><span class="line">  <span class="attribute">margin</span>: <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">a</span> &#123;</span><br><span class="line">  <span class="attribute">text-decoration</span>: none;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">ul</span> &#123;</span><br><span class="line">  <span class="attribute">margin</span>: <span class="number">0</span>;</span><br><span class="line">  <span class="attribute">padding</span>: <span class="number">0</span>;</span><br><span class="line">  <span class="attribute">list-style</span>: none;</span><br><span class="line">&#125;</span><br><span class="line"><span class="selector-tag">img</span> &#123;</span><br><span class="line">  <span class="attribute">vertical-align</span>: top;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="样式关联配置"><a href="#样式关联配置" class="headerlink" title="样式关联配置"></a>样式关联配置</h3><h4 id="vue2-全局scss变量配置"><a href="#vue2-全局scss变量配置" class="headerlink" title="vue2 全局scss变量配置"></a>vue2 全局scss变量配置</h4><ol>
<li>去除<code>webpack.base.conf.js</code>的scss配置</li>
</ol>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">test</span>: <span class="regexp">/\.scss$/</span>,</span><br><span class="line">    <span class="attr">loaders</span>: [<span class="string">&quot;style&quot;</span>, <span class="string">&quot;css&quot;</span>, <span class="string">&quot;sass&quot;</span>]</span><br><span class="line">&#125;,</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>进入<code>build/utils</code></li>
</ol>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br></pre></td><td class="code"><pre><span class="line">	<span class="keyword">function</span> <span class="title function_">resolveResouce</span>(<span class="params">name</span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> path.<span class="title function_">resolve</span>(__dirname, <span class="string">&quot;../src/assets/styles/&quot;</span> + name);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">function</span> <span class="title function_">generateLoaders</span>(<span class="params">loader, loaderOptions</span>) &#123;</span><br><span class="line">        <span class="keyword">var</span> loaders = [</span><br><span class="line">            cssLoader,</span><br><span class="line">            <span class="comment">//添加部分1</span></span><br><span class="line">            &#123;</span><br><span class="line">                <span class="attr">loader</span>: <span class="string">&quot;sass-resources-loader&quot;</span>,</span><br><span class="line">                <span class="attr">options</span>: &#123;</span><br><span class="line">                    <span class="comment">//这是用到的sass文件，多个文件时用数组的形式传入，这是带有变量和mixin的scss文件</span></span><br><span class="line">                    <span class="attr">resources</span>: [<span class="title function_">resolveResouce</span>(<span class="string">&quot;global-style.scss&quot;</span>)],</span><br><span class="line">                &#125;,</span><br><span class="line">            &#125;,</span><br><span class="line">        ];</span><br><span class="line">        <span class="keyword">if</span> (loader) &#123;</span><br><span class="line">            loaders.<span class="title function_">push</span>(&#123;</span><br><span class="line">                <span class="attr">loader</span>: loader + <span class="string">&quot;-loader&quot;</span>,</span><br><span class="line">                <span class="attr">options</span>: <span class="title class_">Object</span>.<span class="title function_">assign</span>(&#123;&#125;, loaderOptions, &#123;</span><br><span class="line">                    <span class="attr">sourceMap</span>: options.<span class="property">sourceMap</span>,</span><br><span class="line">                &#125;),</span><br><span class="line">            &#125;);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// Extract CSS when that option is specified</span></span><br><span class="line">        <span class="comment">// (which is the case during production build)</span></span><br><span class="line">        <span class="keyword">if</span> (options.<span class="property">extract</span>) &#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="title class_">ExtractTextPlugin</span>.<span class="title function_">extract</span>(&#123;</span><br><span class="line">                <span class="attr">use</span>: loaders,</span><br><span class="line">                <span class="attr">fallback</span>: <span class="string">&quot;vue-style-loader&quot;</span>,</span><br><span class="line">                <span class="attr">publicPath</span>: <span class="string">&quot;../../&quot;</span>,</span><br><span class="line">            &#125;);</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            <span class="keyword">return</span> [<span class="string">&quot;vue-style-loader&quot;</span>].<span class="title function_">concat</span>(loaders);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> &#123;</span><br><span class="line">        <span class="attr">css</span>: <span class="title function_">generateLoaders</span>(),</span><br><span class="line">        <span class="attr">postcss</span>: <span class="title function_">generateLoaders</span>(),</span><br><span class="line">        <span class="attr">less</span>: <span class="title function_">generateLoaders</span>(<span class="string">&quot;less&quot;</span>),</span><br><span class="line">        <span class="attr">sass</span>: <span class="title function_">generateLoaders</span>(<span class="string">&quot;sass&quot;</span>, &#123; <span class="attr">indentedSyntax</span>: <span class="literal">true</span> &#125;),</span><br><span class="line">        <span class="comment">//添加部分2,增加.concat....</span></span><br><span class="line">        <span class="attr">scss</span>: <span class="title function_">generateLoaders</span>(<span class="string">&quot;sass&quot;</span>).<span class="title function_">concat</span>(&#123;</span><br><span class="line">            <span class="attr">loader</span>: <span class="string">&quot;sass-resources-loader&quot;</span>,</span><br><span class="line">            <span class="attr">options</span>: &#123;</span><br><span class="line">                <span class="attr">resources</span>: path.<span class="title function_">resolve</span>(</span><br><span class="line">                    __dirname,</span><br><span class="line">                    <span class="string">&quot;../src/assets/styles/global-style.scss&quot;</span></span><br><span class="line">                ), <span class="comment">//全局样式文件</span></span><br><span class="line">            &#125;,</span><br><span class="line">        &#125;),</span><br><span class="line">        <span class="attr">stylus</span>: <span class="title function_">generateLoaders</span>(<span class="string">&quot;stylus&quot;</span>),</span><br><span class="line">        <span class="attr">styl</span>: <span class="title function_">generateLoaders</span>(<span class="string">&quot;stylus&quot;</span>),</span><br><span class="line">    &#125;;</span><br><span class="line">&#125;;</span><br></pre></td></tr></table></figure>


<h3 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h3><ul>
<li>锚点平滑滚动 html添加 <code>scroll-behavior: smooth;</code></li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">lzoxun</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/2023/07/22/web/style/style-css3/">http://example.com/2023/07/22/web/style/style-css3/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">学习笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2023/07/22/web/visualization/day03-svg/" title="数据可视化话 - svg"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">数据可视化话 - svg</div></div></a></div><div class="next-post pull-right"><a href="/2023/07/22/web/style/style-flex/" title="flex基础"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">flex基础</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">lzoxun</div><div class="author-info__description"></div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">108</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">0</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/liaozhongxun"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/liaozhongxun" target="_blank" title="Github"><i class="fab fa-github" style="color: #24292e;"></i></a><a class="social-icon" href="mailto:869664233@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope" style="color: #4a7dbe;"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">这是我的文档</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#CSS3%E6%96%B0%E5%A2%9E%E5%B1%9E%E6%80%A7"><span class="toc-number">1.</span> <span class="toc-text">CSS3新增属性</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A7%BB%E5%8A%A8%E7%AB%AF%E9%80%82%E9%85%8D"><span class="toc-number">2.</span> <span class="toc-text">移动端适配</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%B1%8F%E5%B9%95%E5%B0%BA%E5%AF%B8"><span class="toc-number">2.1.</span> <span class="toc-text">屏幕尺寸</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%B1%8F%E5%B9%95%E5%88%86%E8%BE%A8%E7%8E%87"><span class="toc-number">2.2.</span> <span class="toc-text">屏幕分辨率</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%83%8F%E7%B4%A0"><span class="toc-number">2.3.</span> <span class="toc-text">像素</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AA%92%E4%BD%93%E6%9F%A5%E8%AF%A2"><span class="toc-number">3.</span> <span class="toc-text">媒体查询</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%8A%A0%E8%BD%BD%E6%96%B9%E5%BC%8F"><span class="toc-number">3.1.</span> <span class="toc-text">加载方式</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%82%E9%85%8D%E6%96%B9%E6%A1%88"><span class="toc-number">4.</span> <span class="toc-text">适配方案</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#vw%E9%80%82%E9%85%8D%E6%96%B9%E6%A1%88"><span class="toc-number">4.1.</span> <span class="toc-text">vw适配方案</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#rem-%E9%80%82%E9%85%8D%E6%96%B9%E6%A1%88"><span class="toc-number">4.2.</span> <span class="toc-text">rem 适配方案</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#vue2"><span class="toc-number">4.2.1.</span> <span class="toc-text">vue2</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#vue3"><span class="toc-number">4.2.2.</span> <span class="toc-text">vue3</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A7%BB%E5%8A%A8%E7%AB%AF%E5%B8%B8%E7%94%A8%E9%BB%98%E8%AE%A4%E6%A0%B7%E5%BC%8F"><span class="toc-number">5.</span> <span class="toc-text">移动端常用默认样式</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A0%B7%E5%BC%8F%E5%85%B3%E8%81%94%E9%85%8D%E7%BD%AE"><span class="toc-number">6.</span> <span class="toc-text">样式关联配置</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#vue2-%E5%85%A8%E5%B1%80scss%E5%8F%98%E9%87%8F%E9%85%8D%E7%BD%AE"><span class="toc-number">6.1.</span> <span class="toc-text">vue2 全局scss变量配置</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%85%B6%E4%BB%96"><span class="toc-number">7.</span> <span class="toc-text">其他</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-11/" title="win 11 set">win 11 set</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-gitbash/" title="git bash">git bash</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-wsl/" title="wsl">wsl</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/window/win-main/" title="window">window</a><time datetime="2023-07-22T07:14:09.700Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/2023/07/22/web/%E5%85%BC%E5%AE%B9%E9%97%AE%E9%A2%98/" title="兼容问题">兼容问题</a><time datetime="2023-07-22T07:14:09.699Z" title="发表于 2023-07-22 15:14:09">2023-07-22</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By lzoxun</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (false){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><div class="js-pjax"></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div class="no-result" id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":100,"height":200,"right":300},"mobile":{"show":true}});</script></body></html>